]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/private: Set sampling_radius to match the blur radius
authorDaniel van Vugt <daniel.van.vugt@canonical.com>
Thu, 24 Jun 2021 10:19:09 +0000 (18:19 +0800)
committerMarge Bot <marge-bot@gnome.org>
Tue, 29 Jun 2021 22:32:24 +0000 (22:32 +0000)
From [the spec](https://www.w3.org/TR/css-backgrounds-3/#shadow-blur):

> the resulting shadow must approximate (with each pixel being within 5%
> of its expected value) the image that would be generated by applying to
> the shadow a Gaussian blur with a standard deviation [sigma] equal to
> half the blur radius

This does not change the value of `sigma`, it only corrects the value of
`sampling_radius` used to size the shadow texture. Since the texture is
no longer being slightly oversized it won't get scaled down when rendered
according to the dimensions provided by `st_shadow_get_box` in
`_st_paint_shadow_with_opacity`.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4409
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1897>

src/st/st-private.c

index 5bbefa76316d763320714ced70f498503b68738f..540bad425ebe2766bdb5f83dd06355e2a5637f5f 100644 (file)
@@ -400,8 +400,9 @@ _st_create_shadow_pipeline (StShadow    *shadow_spec,
   g_return_val_if_fail (shadow_spec != NULL, NULL);
   g_return_val_if_fail (src_texture != NULL, NULL);
 
-  sigma = resource_scale * shadow_spec->blur / 2.f;
-  sampling_radius = ceilf (1.5 * sigma) * 2.0;
+  sampling_radius = resource_scale * shadow_spec->blur;
+  sigma = sampling_radius / 2.f;
+  sampling_radius = ceilf (sampling_radius);
 
   src_width = cogl_texture_get_width (src_texture);
   src_height = cogl_texture_get_height (src_texture);